package cn.tpshion.vm.controller;

import cn.tpshion.vm.common.model.Result;
import cn.tpshion.vm.domain.dto.user.AddUserDTO;
import cn.tpshion.vm.domain.vo.UserVO;
import cn.tpshion.vm.service.UserService;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    @GetMapping("/userList")
    public Result<List<UserVO>> userList(){
        return Result.ok(userService.getUserList());
    }

    @PostMapping("/addUser")
    public Result addUser(@Valid @RequestBody AddUserDTO dto){
        userService.addUser(dto);
        return Result.ok();
    }
}
